package com.science.slam.exception;


import com.science.slam.response.BasicResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;

@RestControllerAdvice
public class GlobalExceptionService {
    @ExceptionHandler(BusinessException.class)
    public BasicResponse<Object> businessException(BusinessException exception) {
        return new BasicResponse<>(exception.getCode(), exception.getMessage(), null);
    }

    @ExceptionHandler(IOException.class)
    public BasicResponse<Object> ioException(IOException e) {
        return new BasicResponse<>(-1, "文件保存失败", null);
    }
}
